<?php
include_once "conn.php";
$author = $_POST['author'];
$bookname = $_POST['bookname'];
$code = $_POST['code'];
$fanyi = $_POST['fanyi'];
$page = $_POST['page'];
$price = $_POST['price'];
$booktype = $_POST['booktype'];
$chuban = $_POST['chuban'];
$shujia = $_POST['shujia'];
$kucun = $_POST['kucun'];
$main = new main();
$check = $main ->checkbacode($code);
if ($check){
    $a['error']= 2;//barcode重复
}
else{
    $result = $main-> addbookinfo($code,$bookname,$booktype,$author,$fanyi,$chuban,$price,$page,$shujia,$kucun,time());
    if ($result==1){
        $a['error']= 1;//成功
    }
    else{
        $a['error']=0;
    }
}

echo json_encode($a);